const faker = require('faker');

// 生成用户数据的函数
const generateUsers = (count) => {
  return Array.from({ length: count }, (_, index) => ({
    id: index + 1,
    username: faker.internet.userName(),
    email: faker.internet.email(),
    avatar: faker.image.avatar(),
    password: faker.internet.password(),
  }));
};

// 生成帖子数据的函数
const generatePosts = (count, usersCount) => {
  return Array.from({ length: count }, (_, index) => ({
    id: index + 1,
    title: faker.lorem.words(),
    content: faker.lorem.paragraph(),
    userId: faker.random.number({ min: 1, max: usersCount }),
  }));
};

// 生成评论数据的函数
const generateComments = (count, usersCount, postsCount) => {
  return Array.from({ length: count }, (_, index) => ({
    id: index + 1,
    text: faker.lorem.sentence(),
    userId: faker.random.number({ min: 1, max: usersCount }),
    postId: faker.random.number({ min: 1, max: postsCount }),
  }));
};

module.exports = {
  generateUsers,
  generatePosts,
  generateComments,
}
